<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
        * {
            margin: 0;
            padding: 0;
        }
        
        ul,
        li {
            list-style: none;
        }
        
        .wp {
            width: 300px;
            height: 300px;
            border: 1px solid red;
            margin: 100px;
            position: relative;
        }
        
        li,
        span {
            position: absolute;
            width: 100px;
            height: 100px;
            border: 1px solid blue;
            background-color: pink;
            font-size: 30px;
            text-align: center;
            box-sizing: border-box;
            line-height: 100px;
        }
        
        li:nth-child(2) {
            left: 100px;
        }
        
        li:nth-child(3) {
            left: 200px;
        }
        
        li:nth-child(4) {
            left: 200px;
            top: 100px;
        }
        
        li:nth-child(5) {
            left: 200px;
            top: 200px;
        }
        
        li:nth-child(6) {
            left: 100px;
            top: 200px;
        }
        
        li:nth-child(7) {
            top: 200px;
        }
        
        li:nth-child(8) {
            top: 100px;
        }
        
        span {
            left: 100px;
            top: 100px;
            cursor: pointer;
        }
        
        li.on {
            background-color: blue;
            color: #fff;
            font-weight: bold;
            border: none;
        }
    </style>
</head>

<body>
    <div class="wp">
        <ul>
            <li class="on">程瑞峰</li>
            <li>迟明旭</li>
            <li>邓霜楠</li>
            <li>邓岩松</li>
            <li>杜晓祺</li>
            <li>冯密玺</li>
            <li>高然</li>
            <li>高腾</li>
        </ul>
        <span id="start">开始</span>
    </div>





    <script>
        let lis = document.querySelectorAll("li");
        let index = 0;
        let timer;

        start.onclick = function() {
            let num = Math.floor(Math.random() * 3000 + 1500);
            clearInterval(timer);
            timer = setInterval(function() {
                num -= 200
                if (num <= 200) {
                    clearInterval(timer);
                    alert(`恭喜${document.querySelector(".on").innerHTML}中奖了`)
                    return;
                }
                lis.forEach(item => {
                    item.className = "";
                })
                index = ++index % lis.length;
                lis[index].className = "on";
            }, 100)
        }

        let x = prompt("请你输入内容")
        console.log(x)
    </script>




    <!-- <script>
        let lis = document.querySelectorAll("li");
        let index = 0;
        let timer;
        start.onclick = function() {
            let num = Math.floor(Math.random() * 3000);
            timer = setInterval(function() {
                num -= 200;
                if (num <= 200) {
                    alert(`恭喜${document.querySelector(".on").innerHTML}中奖了`);
                    clearInterval(timer);
                    timer = undefined;
                    return;
                }
                lis.forEach(function(item) {
                    item.className = "";
                })
                index = ++index % lis.length;
                lis[index].className = "on";
            }, 100)
        }
    </script> -->
</body>

</html>0